< previous page page_175 next page >

Page 175
    On Error GoTo PicErr ' in case user picks a bad file
    If Len(CMDialog1.filename) <> 0 Then
       Image1.Picture = LoadPicture(CMDialog1.filename)
    End If
    '
    ' all done, go to exit
    GoTo PicExit
    '
    ' handle bad picture error
PicErr:
    MsgBox "Unable to load selected file.", vbExclamation, "Picture Error"
    Resume Next
    '
    ' final exit of procedure
PicExit:
    '
End Sub
The code in Listing 5.54 sets file type and caption properties of the common dialog box, runs the dialog, and then, if a file has been selected, attempts to save it to the image control. You add a little error trapping here in case the user selects an invalid file type.
Adding Input Validation
The last step in creating Visual Basic 5 data entry forms is adding the input validation routines. The following is a list of the input rules you should use when coding the validation routines:
· The following fields are required for each form:
e7ae6bd512ad4c3583017fcda52f57ae.gif
CompanyName
e7ae6bd512ad4c3583017fcda52f57ae.gif
Addr1
e7ae6bd512ad4c3583017fcda52f57ae.gif
City
e7ae6bd512ad4c3583017fcda52f57ae.gif
State/Province
· The following dependent field rules apply to the form:
e7ae6bd512ad4c3583017fcda52f57ae.gif
If the Addr2 field has data, the Addr1 field must have data.
e7ae6bd512ad4c3583017fcda52f57ae.gif
If the FirstName field has data, the LastName field must have data.
· The StateProv field should allow only uppercase data entry.
First, set the UpperCase property of the vxtStateProv control to True. This forces all data input into this control to upper case. You can accomplish most of these validation checks using the Required property of the new VText control. However, you also need to call the conditionalValidate method for the three controls that require conditional input.

 
< previous page page_175 next page >

If you like this book, buy it!